package com.authine.cloudpivot.ext.applicationservice;

import com.alibaba.fastjson.JSONObject;
import com.authine.cloudpivot.ext.constants.AppConst;
import com.authine.cloudpivot.ext.constants.ScheduleUrlConst;
import com.authine.cloudpivot.ext.constants.ServiceUrlConst;
import com.authine.cloudpivot.ext.dto.system.TriggerMetaDto;
import com.authine.cloudpivot.ext.utils.HttpClients;
import com.authine.common.util.DateUtils;
import javafx.concurrent.ScheduledService;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

/**
 * @program: gomro
 * @description:
 * @author: wlw
 * @create: 2021-11-10 11:35
 **/
@Slf4j
public class JobService {
    private static final String id = "45294914690026496";
    public static final String UPDATE_JOB_URL = "/application/invoke?action=/ScheduledService/updateJob";

    static{
        TriggerMetaDto metaDto = new TriggerMetaDto();
        metaDto.setId(id);
        metaDto.setAppCode(AppConst.PROVIDEGOOD);
        metaDto.setUrl(ScheduleUrlConst.SCORESTATISTICS_JOB);
        metaDto.setDesc("供应商评分定时触发器");
        metaDto.setBody("{\"test\":1}");
        //时间转Cron表达式 每月1号凌晨1点
        metaDto.setCron("0 0 1 1 * ?");
        String url = HttpClients.getUrl(AppConst.SYSTEM_MANAGEMENT, UPDATE_JOB_URL);
        log.info("供应商评分定时触发器 参数：{}",metaDto);
        String execute = HttpClients.execute(url, metaDto);
        log.info("供应商评分定时触发器 响应：{}",execute);

    }
}
